#!/bin/bash
jarFile="eureka-server-0.0.1.jar"
count=`find . -maxdepth 1 -name "$jarFile"|wc -l`
if [ "$count" -le 0 ] ; then
    echo "脚本所在目录下没有jar文件"
    exit 0
fi

################  准备要执行的参数 ################
process1=`ps -ef|grep "java -jar"|grep "$jarFile" | grep "8761" |grep -v grep|awk '{print $2}'`
process2=`ps -ef|grep "java -jar"|grep "$jarFile" | grep "8762" |grep -v grep|awk '{print $2}'`
process3=`ps -ef|grep "java -jar"|grep "$jarFile" | grep "8763" |grep -v grep|awk '{print $2}'`
if [ -n "$process1" ] ; then
    kill -9 $process1
fi
if [ -n "$process2" ] ; then
    kill -9 $process2
fi
if [ -n "$process3" ] ; then
    kill -9 $process3
fi
nohup java -jar $jarFile --spring.profiles.active=8761 > /dev/null 2>&1 &
nohup java -jar $jarFile --spring.profiles.active=8762 > /dev/null 2>&1 &
nohup java -jar $jarFile --spring.profiles.active=8763 > /dev/null 2>&1 &

